package com.huatai.range.controller;

import com.huatai.common.api.R;
import com.huatai.range.request.CreateTabRequest;
import com.huatai.range.service.CreateTabService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName CreateTabController
 * @Description TODO
 * @Author luoxc
 * @Date 2023/4/17 15:13
 * @Version 1.0
 */
@RestController
@RequestMapping("table")
@Api(tags = "GIS表管理", value = "GIS表管理")
public class CreateTabController {

	@Autowired
	private CreateTabService createTabService;

	@GetMapping("dropTab")
	@ApiOperation(value = "删除表", notes = "删除表")
	public R dropTab(@ApiParam(name = "tabName", value = "表名", required = true) @RequestParam("tabName") String tabName){
		return R.data(createTabService.dropTab(tabName));
	}

	@GetMapping("existTab")
	@ApiOperation(value = "表是否存在", notes = "表是否存在")
	public R existTab(@ApiParam(name = "tabName", value = "表名", required = true) @RequestParam("tabName") String tabName){
		return R.data(createTabService.existTab(tabName));
	}

	@PostMapping("createTab")
	@ApiOperation(value = "创建表", notes = "创建表")
	public R create(@RequestBody CreateTabRequest createTabRequest){
		return R.data(createTabService.create(createTabRequest));
	}
}
